import request from '@/utils/request';

export function listUsers() {
  return request({
    url: '/users/list',
    method: 'get',
  });
}

interface UpdateUser {
  avatar?: string,
  email?: string,
  nickName?: string,
  birthday?: number | Date | string,
  phone?: string,
  remark?: string
}

export function updateUser(user: UpdateUser) {
  return request({
    url: '/users/update',
    method: 'post',
    data: user
  });
}

export function findUserByUserName(username: any) {
  return request({
    url: '/users/' + username,
    method: 'get'
  })
}

/**
 * @param keyword 
 * @returns 
 */
export function findUserByKeyword(keyword: string) {
  return request({
    url: '/users/list/' + keyword,
    method: 'get'
  })
}


// interface FindUserQuery{
//   userName?: string, // 用户名
//   nickName?: string, // 昵称
//   email?: string,   // 邮箱
//   phone?: string,   // 手机号
// }

/**
 * 
 * @param query 根据条件查询 0 账号 1 昵称 2 手机号
 * @param keyword 
 * @returns 
 */
export function findUser(keyword: string) {
  return request({
    url: '/users/find/' + keyword,
    method: 'get'
  })
}

export function modifyPwd(data: any) {
  return request({
    url: '/users/modifyPwd',
    method: 'post',
    data: data
  })
}
